// pages/zhuren/zhuren.js
import * as echarts from '../../ec-canvas/echarts' // 这个是自己实际的目录

let app=getApp();

function initChart1(canvas, width, height, dpr) {
    const chart = echarts.init(canvas, null, {
      width: width,
      height: height,
      devicePixelRatio: dpr // new
    });
    canvas.setChart(chart);
   
    var option = {
      title: {
        text: '就业质量',
        left: '5%'
      },
      color: ['#5087ec', '#85d0dc', '#58a55c'],
      legend: {
        data: ['前端开发', '短视频运营', '大数据'],
        top: 50,
        left: 'center',
        z: 100
      },
      grid: {
        containLabel: true,
        top: '100'
      },
      tooltip: {
        show: true,
        trigger: 'axis'
      },
      xAxis: {
        type: 'category',
        boundaryGap: false,
        data: ['C2109班'],
        // show: false
      },
      yAxis: {
        x: 'center',
        type: 'value',
        splitLine: {
          lineStyle: {
            type: 'solid'
          }
        }
        // show: false
      },
      series: [{
        name: '前端开发',
        type: 'bar',
        smooth: true,
        data: [20],
        barGap:0
      }, {
        name: '短视频运营',
        type: 'bar',
        smooth: true,
        data: [15]
      }, {
        name: '大数据',
        type: 'bar',
        smooth: true,
        data: [30]
      }]
    };
   
    chart.setOption(option);
    return chart;
  }
  
  
  //就业率
  function initChart2(canvas, width, height, dpr) {
    const chart = echarts.init(canvas, null, {
       width: width,
       height: height,
       devicePixelRatio: dpr // new
     });
     canvas.setChart(chart);
   
     var option = {
       title: {
         text: '就业率',
         left: '5%'
       },
       tooltip: {
         trigger: 'axis',
         axisPointer: {            // 坐标轴指示器，坐标轴触发有效
           type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
         },
         confine: true
       },
       legend: {
         data: []
       },
       grid: {
         left: 20,
         right: 20,
         bottom: 15,
         top: 40,
         containLabel: true
       },
       xAxis: [
         {
           type: 'value',
           axisLine: {
             lineStyle: {
               color: '#999'
             }
           },
           axisLabel: {
             color: '#666'
           }
         }
       ],
       yAxis: [
         {
           type: 'category',
           axisTick: { show: false },
           data: ['前端', '短视频', '大数据', '全栈', '测试', '人工智能'],
           axisLine: {
             lineStyle: {
               color: '#999'
             }
           },
           axisLabel: {
             color: '#666'
           }
         }
       ],
       series: [
         {
           name: '热度',
           type: 'bar',
           label: {
             normal: {
               show: true,
               position: 'inside'
             }
           },
           data: [300, 270, 340, 344, 300, 320, 310],
           itemStyle: {
             // emphasis: {
             //   color: '#37a2da'
             // }
           }
         }
        
       ]
     };
   
     chart.setOption(option);
     return chart;
   }
   
   //面试量
   function initChart3(canvas, width, height, dpr) {
     const chart = echarts.init(canvas, null, {
       width: width,
       height: height,
       devicePixelRatio: dpr // new
     });
     canvas.setChart(chart);
    
     var option = {
       title: {
         text: '面试量',
         left: '5%'
       },
       color: ['#5087ec', '#85d0dc'],
       legend: {
         data: ['前端', '短视频','大数据','全栈'],
         top: 50,
         left: 'center',
         z: 100
       },
       grid: {
         containLabel: true,
         top: '100'
       },
       tooltip: {
         show: true,
         trigger: 'axis'
       },
       xAxis: {
         type: 'category',
         boundaryGap: false,
         data: ['周一','周二','周三','周四','周五'],
         // show: false
       },
       yAxis: {
         x: 'center',
         type: 'value',
         splitLine: {
           lineStyle: {
             type: 'solid'
           }
         }
         // show: false
       },
       series: [{
         name: '前端',
         type: 'line',
         smooth: false,
         data: [10,20,30,55,70]
       }, {
         name: '短视频',
         type: 'line',
         smooth: false,
         data: [15,22,50,70,80]
       }, {
         name: '大数据',
         type: 'line',
         smooth: false,
         data: [15,22,50,70,80]
       }, {
         name: '全栈',
         type: 'line',
         smooth: false,
         data: [15,22,50,70,80]
       }]
     };
    
     chart.setOption(option);
     return chart;
   }
   
   //环比
   function initChart5(canvas, width, height, dpr) {
     const chart = echarts.init(canvas, null, {
       width: width,
       height: height,
       devicePixelRatio: dpr // new
     });
     canvas.setChart(chart);
    
     var option = {
       title: {
         text: '环比',
         left: '5%'
       },
       color: ['#5087ec', '#85d0dc'],
       legend: {
         data: ['上周', '本周'],
         top: 50,
         left: 'center',
         z: 100
       },
       grid: {
         containLabel: true,
         top: '100'
       },
       tooltip: {
         show: true,
         trigger: 'axis'
       },
       xAxis: {
         type: 'category',
         boundaryGap: false,
         data: ['周一','周二','周三','周四','周五'],
         // show: false
       },
       yAxis: {
         x: 'center',
         type: 'value',
         splitLine: {
           lineStyle: {
             type: 'solid'
           }
         }
         // show: false
       },
       series: [{
         name: '上周',
         type: 'line',
         smooth: false,
         data: [10,20,30,55,70]
       }, {
         name: '本周',
         type: 'line',
         smooth: false,
         data: [15,22,50,70,80]
       }]
     };
    
     chart.setOption(option);
     return chart;
   }
   
   //毕业人数
   function initChart4(canvas, width, height, dpr) {
     const chart = echarts.init(canvas, null, {
       width: width,
       height: height,
       devicePixelRatio: dpr // new
     });
     canvas.setChart(chart);
    
     var option = {
       title: {
         text: '毕业人数',
         left: '5%'
       },
       color: ['#5087ec', '#85d0dc', '#58a55c'],
       legend: {
         data: ['C2109A班', 'C2109B班', 'C2109C班'],
         top: 50,
         left: 'center',
         z: 100
       },
       grid: {
         containLabel: true,
         top: '100'
       },
       tooltip: {
         show: true,
         trigger: 'axis'
       },
       xAxis: {
         type: 'category',
         boundaryGap: false,
         data: ['C2109班'],
         // show: false
       },
       yAxis: {
         x: 'center',
         type: 'value',
         splitLine: {
           lineStyle: {
             type: 'solid'
           }
         }
         // show: false
       },
       series: [{
         name: 'C2109A班',
         type: 'bar',
         smooth: true,
         data: [20],
         barGap:0
       }, {
         name: 'C2109B班',
         type: 'bar',
         smooth: true,
         data: [15]
       }, {
         name: 'C2109C班',
         type: 'bar',
         smooth: true,
         data: [30]
       }]
     };
    
     chart.setOption(option);
     return chart;
   }
  
Page({

    /**
     * 页面的初始数据
     */
    data: {
        active: 0,
        dataList:{},
        list:{
            user:'廖主任',
            zhiwu:'主任',
            fangxiang:'管理部门'
          },
          value2: 'a',
          option2: [
            { text: '当期', value: 'a' },
            { text: '2108', value: 'b' },
            { text: '2107', value: 'c' },
            { text: '2106', value: 'd' },
            { text: '2105', value: 'e' },
            { text: '2104', value: 'f' },
            { text: '半年内', value: 'g' },
            { text: '一年内', value: 'h' }
          ],
          ec: {
            onInit: initChart1
          },
          ec2: {
            onInit: initChart2
          },
          ec3: {
            onInit: initChart3
          },
          ec4: {
            onInit: initChart4
          },
          ec5: {
            onInit: initChart5
          }
    },
    onChange(e) {
        // console.log("e:", e);
        this.setData({
            active: e.detail.index
        })
    },
    onClickLeft() {
        wx.showToast({
            title: '点击返回',
            icon: 'none'
        });
    },
    onClickRight() {
        wx.showToast({
            title: '点击按钮',
            icon: 'none'
        });
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        app.http.zrShouYe({"college":5,"type":"2108"}).then(res=>{
            console.log("res:",res);
            if(res.data.code == 200){
                this.setData({
                    dataList:res.data.data
                })
                console.log(this.data.dataList);
            }
          })
     
    },
    
})